package com.idlestar.androiddocs.net;

import android.text.TextUtils;

import com.alibaba.fastjson.JSONObject;
import com.android.volley.Request;
import com.android.volley.toolbox.StringRequest;

import java.util.HashMap;

/**
 * 网络请求管理类。
 * 2016/8/18.
 */
public class NetClient {
    private static final String DEFAULT_REQUEST_TAG = "com.idlestar.androiddocs.net.NetClient";
    private static NetClient sInstance = new NetClient();
    private NetClient() {}

    public static NetClient instance() {
        return sInstance;
    }


    public static abstract class RequestListener<T> {
        public void onEnd() {};
        public abstract void onSuccess(int responseCode, T data);
        public abstract void onError(int errorCode, String errorInfo);
    }

    public void cancelPendingRequests(Object tag) {

    }

    public static StringRequest newPostStringRequest(String url, HashMap<String, String> params, RequestListener listener) {
        return null;
    }

    public <T> void addToRequestQueue(Request<T> req , String tag) {
        req.setTag(TextUtils.isEmpty(tag) ? DEFAULT_REQUEST_TAG : tag);
        //Log.d("Adding request to queue: %s", req.getUrl());
        //getRequestQueue().add(req);
    }
}
